<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>com class constructor</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="class.com.html">« com</a></li>
      <li style="float: right;"><a href="class.dotnet.html">dotnet »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="class.com.html">com</a></li>
    <li>com class constructor</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="com.construct" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">com::__construct</h1>
  <p class="verinfo">(PHP 4 &gt; 4.1.0, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">com::__construct</span> &mdash; <span class="dc-title">com class constructor</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-com.construct-description">
  <h3 class="title">说明</h3>
  <div class="constructorsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><strong>com::__construct</strong></span>(<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type">string</span> <code class="parameter">$module_name</code></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><span class="type">array</span>|<span class="type">string</span>|<span class="type">null</span></span> <code class="parameter">$server_name</code><span class="initializer"> = <strong><code>null</code></strong></span></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type">int</span> <code class="parameter">$codepage</code><span class="initializer"> = <strong><code>CP_ACP</code></strong></span></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type">string</span> <code class="parameter">$typelib</code><span class="initializer"> = &quot;&quot;</span></span><br>)</div>

  <p class="para rdfs-comment">
   Constructs a new com object.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-com.construct-parameters">
  <h3 class="title">参数</h3>
  <dl>
   
    <dt>
<code class="parameter">module_name</code></dt>

    <dd>

     <span class="simpara">
      Can be a ProgID, Class ID or Moniker that names the component to load.
     </span>
     <span class="simpara">
      A ProgID is typically the application or DLL name, followed by a period,
      followed by the object name. e.g: <code class="literal">Word.Application</code>.
     </span>
     <span class="simpara">
      A Class ID is the UUID that uniquely identifies a given class.
     </span>
     <span class="simpara">
      A Moniker is a special form of naming, similar in concept to a URL
      scheme, that identifies a resource and specifies how it should be
      loaded.  As an example, you could load up Word and get an object
      representing a word document by specifying the full path to the word
      document as the module name, or you can use <code class="literal">LDAP:</code> as
      a moniker to use the ADSI interface to LDAP.
     </span>
    </dd>

   
   
    <dt>
<code class="parameter">server_name</code></dt>

    <dd>

     <span class="simpara">
      The name of the DCOM server on which the component should be loaded and
      run.  If <strong><code>null</code></strong>, the object is run using the default for the
      application.  The default is typically to run it on the local machine,
      although the administrator might have configured the application to
      launch on a different machine.
     </span>
     <span class="simpara">
      If a non-<strong><code>null</code></strong> value is specified for server, PHP will refuse to load
      the object unless the <a href="com.configuration.html#ini.com.allow-dcom" class="link">com.allow_dcom</a> <var class="filename">php.ini</var> option
      is set to <strong><code>true</code></strong>.
     </span>
     <p class="para">
      If <code class="parameter">server_name</code> is an array, it should contain the
      following elements (case sensitive!).  Note that they are all optional
      (although you need to specify both Username and Password together); if
      you omit the Server setting, the default server will be used (as
      mentioned above), and the instantiation of the object will not be
      affected by the <a href="com.configuration.html#ini.com.allow-dcom" class="link">com.allow_dcom</a>
      <var class="filename">php.ini</var> directive.
      <table class="doctable table">
       <caption><strong>DCOM server name</strong></caption>
       
        <thead>
         <tr>
          <th>key</th>
          <th>type</th>
          <th>description</th>
         </tr>

        </thead>

        <tbody class="tbody">
         <tr>
          <td>Server</td>
          <td>string</td>
          <td>The name of the server.</td>
         </tr>

         <tr>
          <td>Username</td>
          <td>string</td>
          <td>The username to connect as.</td>
         </tr>

         <tr>
          <td>Password</td>
          <td>string</td>
          <td>The password for <code class="literal">Username</code>.</td>
         </tr>

         <tr>
          <td>Domain</td>
          <td>string</td>
          <td>The domain of <code class="literal">server</code>.</td>
         </tr>

         <tr>
          <td>Flags</td>
          <td>integer</td>
          <td>One or more of the following constants, logically OR&#039;d together:
           <strong><code>CLSCTX_INPROC_SERVER</code></strong>,
           <strong><code>CLSCTX_INPROC_HANDLER</code></strong>,
           <strong><code>CLSCTX_LOCAL_SERVER</code></strong>,
           <strong><code>CLSCTX_REMOTE_SERVER</code></strong>,
           <strong><code>CLSCTX_SERVER</code></strong> and
           <strong><code>CLSCTX_ALL</code></strong>.  The default value if not
           specified here is <strong><code>CLSCTX_SERVER</code></strong> if you also
           omit <code class="literal">Server</code>, or
           <strong><code>CLSCTX_REMOTE_SERVER</code></strong> if you do specify a
           server.  You should consult the Microsoft documentation for
           CoCreateInstance for more information on the meaning of these
           constants; you will typically never have to use them.
          </td>
         </tr>

        </tbody>
       
      </table>

     </p>
    </dd>

   
   
    <dt>
<code class="parameter">codepage</code></dt>

    <dd>

     <span class="simpara">
      Specifies the codepage that is used to convert strings to
      unicode-strings and vice versa.  The conversion is applied whenever a
      PHP string is passed as a parameter or returned from a method of this
      COM object.  The code page is sticky, which means that it will
      propagate to objects and variants returned from the object.
     </span>
     <span class="simpara">
      Possible values are
      <strong><code>CP_ACP</code></strong> (use system default ANSI code page - the
      default if this parameter is omitted),
      <strong><code>CP_MACCP</code></strong>,
      <strong><code>CP_OEMCP</code></strong>, <strong><code>CP_SYMBOL</code></strong>,
      <strong><code>CP_THREAD_ACP</code></strong> (use codepage/locale set for the
      current executing thread), <strong><code>CP_UTF7</code></strong>
      and <strong><code>CP_UTF8</code></strong>.  You may also use the number for a
      given codepage; consult the Microsoft documentation for more details on
      codepages and their numeric values.
     </span>
    </dd>

   
  </dl>

 </div>


</div></div></div></body></html>